//
//  UIBarButtonItem+Category.swift
//  DSWeiBo
//
//  Created by iOS聚商 on 2017/6/29.
//  Copyright © 2017年 dreamSun. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    //如果在func前面加class，就相当于oc中的+方法
    class func creatbarButtonItem(imageName:String,target:AnyObject?, action:Selector) -> UIBarButtonItem {
        let btn = UIButton()
        btn.setImage(UIImage(named:imageName), for: .normal)
        btn.setImage(UIImage(named:imageName+"_highlighted"), for: .highlighted)
        btn.addTarget(target, action: action, for: .touchUpInside)
        btn.sizeToFit()
        return UIBarButtonItem(customView: btn)
    }
    
    
}
